package edu.chalmers;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class SummaryFragment extends Fragment{
	private BookManager bookManager = SharedBookManager.getBookManager();
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstaceState){
		return inflater.inflate(R.layout.summary, container, false);
	}
	
	@Override
	public void onResume() {
		super.onResume();
		View view = getView();
		
		TextView bookCount = (TextView) view.findViewById(R.id.bookCount);
		bookCount.setText(""+bookManager.count());
		TextView totalCost = (TextView) view.findViewById(R.id.totalCost);
		totalCost.setText(bookManager.totalCost() + " SEK");
		TextView mostExpensive = (TextView) view.findViewById(R.id.mostExpensive);
		mostExpensive.setText(bookManager.maxPrice() + " SEK");
		TextView leastExpensive = (TextView) view.findViewById(R.id.leastExpensive);
		leastExpensive.setText(bookManager.minPrice() + " SEK");
		TextView meanPrice = (TextView) view.findViewById(R.id.meanPrice);
		meanPrice.setText(bookManager.meanPrice() + " SEK");
	}
}
